<?php
 
/*
 * Following code will list all the products
 */
 
// array for JSON response
$response = array();
 
// include db connect class
require_once __DIR__ . '/db_connect.php';
 
// connecting to db
$db = new DB_CONNECT();
 
// get all products from products table

//$result = mysql_query("SELECT place_name,address,url_image FROM place") or die(mysql_error());
/*$result = mysql_query("SELECT place_id, 
								place_name,
								address,
								longitude,
								latitude, 
								phone_number,
								fax_number, 
								email, 
								website, 
								open_time, 
								close_time, 
								visa_master, 
								car_parking, 
								moto_parking, 
								delivery, 
								wifi, 
								description, 
								public, 
								delete, 
								date_create, 
								url_image, 
								district_id, 
								lowest_price, 
								hightest_price
								FROM place") or die(mysql_error());*/
$result = mysql_query("SELECT * FROM place") or die(mysql_error());
 
// check for empty result
if (mysql_num_rows($result) > 0) {
    // looping through all results
    // products node
    $response["place"] = array();
 
    while ($row = mysql_fetch_array($result)) {
        // temp user array
        $place = array();    
	$place["place_id"] = $row['place_id'];
    $place["place_name"] = $row['place_name'];
	$place["address"] = $row['address'];
	$place["district_id"] = $row['district_id'];	
	$place["longitude"] = $row['longitude'];
	$place["latitude"] = $row['latitude'];	 
	$place["phone_number"] = $row['phone_number'];
	$place["fax_number"] = $row['fax_number'];
	$place["email"] = $row['email'];
	$place["website"] = $row['website'];
	$place["open_time"] = $row['open_time'];		 
	$place["close_time"] = $row['close_time'];
	$place["lowest_price"] = $row['lowest_price'];
	$place["hightest_price"] = $row['hightest_price'];
	$place["description"] = $row['description'];
	$place["url_avatar"] = $row['url_avatar'];	
	$place["name_avatar"] = $row['name_avatar'];	
	$place["date_create"] = $row['date_create'];
	$place["public"] = $row['public'];
	$place["delete"] = $row['delete'];
	
        // push single product into final response array
        array_push($response["place"], $place);
    }
    // success
    $response["success"] = 1;
 
    // echoing JSON response
    echo json_encode($response);
} else {
    // no products found
    $response["success"] = 0;
    $response["message"] = "No products found";
 
    // echo no users JSON
    echo json_encode($response);
}
?>